home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 58189 / 58189.xpi / modules / Policy.jsm < prev    next >
Text File  |  2010-01-06  |  1KB  |  67 lines

  1. /*
  2.  * This class contains general policy definitions and operations.
  3.  */
  4.  
  5. var EXPORTED_SYMBOLS = [ ];
  6. Components.utils.import("resource://csfiremodules/CsFireCommon.jsm");
  7.  
  8. CsFire.Policy = new function() {
  9.     this.DISABLED = 0;
  10.     this.ACCEPT = 1;
  11.     this.STRIP  = 2
  12.     this.BLOCK  = 3;
  13.     
  14.     this.SRC_CLIENT = 0;
  15.     this.SRC_SERVER = 1;
  16. }
  17.  
  18.  
  19. /*
  20.  * This function converts the numerical decision representation to a textual value.
  21.  */ 
  22. CsFire.Policy.textualDecision = function(decision) {
  23.     var result = "";
  24.  
  25.     if(decision.whitelist) {
  26.         result += "WHITELISTED";
  27.     }
  28.     else {
  29.         switch(decision.source) {
  30.             case this.SRC_CLIENT:    result = "CLIENT - ";
  31.                 break;
  32.             case this.SRC_SERVER:    result = "SERVER - ";
  33.                 break;
  34.         }
  35.     
  36.         switch(decision.action) {
  37.             case this.ACCEPT:    result += "ACCEPT";
  38.                 break;
  39.             case this.STRIP:    result += "STRIP";
  40.                 if(decision.stripAuth != null && decision.stripAuth == true) {
  41.                     result += " (AUTH)";
  42.                 }
  43.                 if(decision.stripCookies != null && decision.stripCookies == true) {
  44.                     result += "(COOKIES"
  45.                     if(decision.cookieExceptions != null) {
  46.                         result += " [";
  47.                         for(cookie in decision.cookieExceptions) {
  48.                             result += cookie;
  49.                             result += ";";
  50.                         }
  51.                         result += "]";
  52.                     }
  53.                     result += ")";
  54.                 }
  55.                 break;
  56.             case this.BLOCK:    result += "BLOCK";
  57.                 break;
  58.             case this.DISABLED:    result += "DISABLED";
  59.                 break;
  60.         }
  61.     }
  62.     
  63.     
  64.     
  65.     return result;
  66. }
  67.